<?php
/*
 * @Descripttion: 关键词
 * @Author: 夜雨
 * @Email: 448408740@qq.com
 * @Date: 2019-11-27 09:51:22
 * @LastEditTime: 2019-12-04 13:14:00
 */
namespace app\admin\controller;

use app\admin\model\Message;
use app\admin\model\Searchword;

class Chart extends Base
{
    
    public function message(){
        if(request()->isAjax()){
            $ism = input('param.ism');
            $date = input('param.date');
            $args = [];
            if (!empty($ism)) $args['ism'] = $ism;
            if (!empty($date)) {
                $pos = strpos($date, ' - ');
                $args['start_date'] = substr($date, 0, $pos);
                $args['end_date'] = substr($date, $pos + 3);
            };
            $model = new Message;
            $count = $model->chartMessageCount($args);
            return json_encode($count);
        }
        return $this->fetch();
    }

    public function searchword(){
        if(request()->isAjax()){
            $ism = input('param.ism');
            $date = input('param.date');
            $args = [];
            if (!empty($ism)) $args['ism'] = $ism;
            if (!empty($date)) {
                $pos = strpos($date, ' - ');
                $args['start_date'] = substr($date, 0, $pos);
                $args['end_date'] = substr($date, $pos + 3);
            };
            $model = new Searchword;
            $data = $model->chartSearchwordCount($args);
            return json_encode($data);
        }
        return $this->fetch();
    }

}